// Lightdome fragment shader

uniform samplerCube diffuseLightMap;
uniform samplerCube specularLightMap;

varying vec2 Texcoord;
varying vec3 ViewDirectionO;
varying vec3 ViewDirection;
varying vec3 Tangent;
varying vec3 Binormal;
varying vec3 Normal;

vec4 fvGetDomeLighting( vec3 texcoord )
{
   mat3 fmTBN = mat3( Tangent, Binormal, Normal );

   vec3 fvViewDirection = normalize( ViewDirectionO );
   vec3 fvNormal = normalize( ( ( texture2D( bumpMap, texcoord ).xyz * 2.0 ) - 1.0 ) );
     
   fvNormal = normalize( fmTBN * fvNormal );
   
   vec3 fvReflection = normalize( reflect( fvViewDirection, fvNormal ) );
   vec4 fvTotalDiffuse = textureCube( diffuseLightMap, fvNormal ); 
   vec4 fvTotalSpecular = textureCube( specularLightMap, fvReflection );
  
   return ( fvTotalDiffuse + fvTotalSpecular );
}
